package com.sakura.controller;

import com.sakura.entity.Shop;
import com.sakura.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by apple on 2018/12/25.
 */
@RestController
public class ShopController {
    @Autowired
    private ShopService service;

    /**
     * 普通数据源  查询master
     * @param id
     * @return
     */
    @RequestMapping(value = "/getShop")
    public Shop getShop(@RequestParam("id") int id) {
        return service.getShop(id);
    }

    @RequestMapping(value = "/test")
    public String test() {
        return "hello world";
        //return service.getShop(id);
    }

    @RequestMapping(value = "/getMasterShop")
    public Shop getMasterShop(@RequestParam("id") int id) {
        return service.getMasterShopByAnnotation(id);
    }

    @RequestMapping(value = "/getSlaverShop")
    public Shop getSlaverShop(@RequestParam("id") int id) {
        return service.getSlaverShopByAnnotation(id);
    }

    @RequestMapping(value = "/updateShopById")
    public String updateShopById(@RequestParam("shopName") String shopName, @RequestParam("id") int id) throws ClassNotFoundException {
        return service.updateShopById(shopName, id);
    }


}
